import { Transform } from "../geom/Transform";
import rootStore from "../../stores";
import { PropertyType } from "../../stores/propertyStore";
import { BoneView } from "../views/BoneView";

class Bone {
    length: number = 0.0;
    alpha: number = 1.0;
    name: string = "";
    parent: string = "";
    index: number = 0;
    transform: Transform = new Transform();

    public notifyUI(): void {
        rootStore.transformBarStore.setTransformData(this);
        rootStore.propertyStore.setType(PropertyType.Bone);
        rootStore.propertyStore.setBoneData(this);
    }

    public setTransform(view: BoneView) {
        this.transform.x = view.position.x;
        this.transform.y = view.position.y;
        this.transform.skew = view.skew.x;
        this.transform.rotation = view.rotation;
        this.transform.scaleX = view.scale.x;
        this.transform.scaleY = view.scale.y;
    }
}

export { Bone };